<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * HITI AdminCP
 *
 * @package     HITI AdminCP Project
 * @since       Monday, October 21, 2013, 6:00 PM
 * @final       
 * @category    Controllers
 * @see 		User logs
 * @author      PHUOCNGUYEN - HITI Dev Team
 * @copyright   Copyright (c) 2013, HITI Corp
 */

class Userlogs extends CI_Controller {
	var $user = '';
	var $q = '';
	var $limit = '';
	var $time_from = '';
	var $time_to = '';
	var $uri_arr = array();
	var $uri_str = '';
	var $site_url = '';

	public function __construct()
	{
		parent::__construct();
		/*
		* Load hiti model
		*/
		$this->load->model('hiti_model', 'hiti', true);
		/*
		* Load config
		*/
		$this->hiti->load_config();
		/*
		* Kiem tra quyen truy cap
		*/
		if (check_rights() == false)
		{
			redirect();
		}
		$this->load->model($GLOBALS['var']['act'].'_model', 'Log', true);
		$this->user = $GLOBALS['var']['user_id'];
		$this->q = $this->input->get('q', true);
		$this->time_from = $this->input->get('from', true);
		$this->time_to = $this->input->get('to', true);
		$this->uri_arr = array(
			'user' => $this->user,
			'q' => $this->q,
			'rowstart' => $GLOBALS['var']['rowstart'],
			'deleted' => '',
			'limit' => $this->limit,
			'from' => $this->time_from, 
			'to' => $this->time_to,
		);
		$this->uri_str = url_uri($this->uri_arr);
		$this->site_url = site_url($GLOBALS['var']['act']);
	}

	public function index()
	{
		/*
		* Xu ly du lieu
		*/
		$num_rows = $this->Log->show($this->uri_arr, true);
		$page_list = page_list($num_rows, $this->uri_arr);
		$data = array(
			'userlogs' => array(),
			'user' => $this->user,
			'page_list' => $page_list,
		);
		$rows = $this->Log->show($this->uri_arr);
		if ($rows) $data['userlogs'] = $rows;
		/*
		* Hien thi
		*/
		$header = array(
			'title' => 'Nhật ký công việc',
			'add_link' => '',
			'search' => true,
			'page_list' => $page_list,
			'datetime_picker' => true,
			'submit_btn' => false,
			'cat_list' => array(),
			'uri' => $this->uri_arr,
			'act' => $GLOBALS['var']['act'],
			'do' => $GLOBALS['var']['do'],
			'id' => $GLOBALS['var']['id'],
			'filter_cat' => $GLOBALS['var']['filter_cat']
		);
		$this->load->view('header', $header);
		$this->load->view($GLOBALS['var']['act'], $data);
		$this->load->view('footer');
	}
}

/* End of file userlogs.php */
/* Location: ./application/controllers/userlogs.php */